package com.epfly.promo.activity.dao;

import com.epfly.promo.activity.entity.ActivityDayBoundEntity;
import org.apache.ibatis.annotations.*;
import tk.mybatis.mapper.additional.insert.InsertListMapper;
import tk.mybatis.mapper.common.BaseMapper;

@Mapper
public interface ActivityDayBoundMapper extends BaseMapper<ActivityDayBoundEntity>, InsertListMapper<ActivityDayBoundEntity> {


    @Delete(value = "delete from tbl_activity_day_bound where activity_id = #{activityId} and del_flag = 0")
    int deleteByActivityId(@Param(value = "activityId") Long activityId);


    @ResultMap(value = "activityDayBoundMapperBaseResultMap")
    @Select(value = "select amount_bound, count_bound, is_active from tbl_activity_day_bound where activity_id = #{activityId} and del_flag = 0")
    ActivityDayBoundEntity findByActivityId(@Param(value = "activityId") Long activityId);


    @ResultMap(value = "activityDayBoundMapperBaseResultMap")
    @Select(value = "select amount_bound, count_bound, is_active from tbl_activity_day_bound where activity_id = #{activityId} and is_active = #{isActive} and del_flag = 0")
    ActivityDayBoundEntity findByActivityIdAndIsActive(@Param(value = "activityId") Long activityId, @Param(value = "isActive") Byte isActive);

}
